
/*
 * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
 *
 * (b)  If this Sample Code is distributed as part of the Display PostScript
 *	System Software Development Kit from Adobe Systems Incorporated,
 *	then this copy is designated as Development Software and its use is
 *	subject to the terms of the License Agreement attached to such Kit.
 *
 * (c)  If this Sample Code is distributed independently, then the following
 *	terms apply:
 *
 * (d)  This file may be freely copied and redistributed as long as:
 *	1) Parts (a), (d), (e) and (f) continue to be included in the file,
 *	2) If the file has been modified in any way, a notice of such
 *      modification is conspicuously indicated.
 *
 * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
 *	Adobe Systems Incorporated.
 * 
 * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
 *	CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
 *	AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
 *	ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
 *	OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
 *	WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
 *	WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
 *	DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
 *	FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
 *	OF THIRD PARTY RIGHTS.
 */

/*
 *	NXBitmapImageRepSub.m
 *
 *	A subclass of NXBitmapImageRep. Enhanced to handle rotation
 *	and resources.
 *
 *	Version:	2.0
 *	Author:	Ken Fromm
 */

#import "NXBitmapImageRepSub.h"

#import <appkit/Panel.h>
#import <appkit/View.h>
#import <appkit/nextstd.h>

#import <objc/List.h>
#import <objc/hashtable.h>
#import <dpsclient/wraps.h>

@implementation NXBitmapImageRepSub

/*
*	Used when printing. Add the resources used in this file
*	to the list passed in. Adds the filename if it exists and if
*	it is not currently in the resourceDoc structure.
*/
- addResources:(Resource *) resourceDoc  forFile:(NXAtom) fileName
{
	id			name;

 	int			i;

	if (_fileName || fileName)
	{
		i = RES_SUPPLIED;
		if (_fileName)
		{
			name = (id) _fileName;
			if (NXDrawingStatus == NX_COPYING)
				i = RES_NEEDED;
		}
		else
			name = (id) fileName;

		if (!resourceDoc[RES_FILES].states[RES_PRESENT])
			resourceDoc[RES_FILES].states[RES_PRESENT] = [List  new];
		if (!resourceDoc[RES_FILES].states[RES_NEEDED])
			resourceDoc[RES_FILES].states[i] = [List  new];

		[resourceDoc[RES_FILES].states[RES_PRESENT]  addObjectIfAbsent:name];
		[resourceDoc[RES_FILES].states[i]  addObjectIfAbsent:name];
	}

	return self;
}

/*
 *	Draws the Tiff file. Positions it appropriately, scaling and rotating
 *	it according to the arguments passed in. The rotation is in degrees.
 */
- (BOOL) drawIn:(NXRect *) r  with:(float) rotation
{
	BOOL		error;

	error = NO;
	if (NXDrawingStatus == NX_COPYING)
	{
		if (_fileName)
		{
		}
		else
		{
		}
	}
	else
	{
		PSgsave();
		PStranslate(r->origin.x, r->origin.y);
		PSrotate(rotation);
		PSscale(r->size.width/size.width, r->size.height/size.height);

		error = [self  draw];
		PSgrestore();
	}

	return error;
}

@end
